package stat;

import loadsave.Memento;
import loadsave.loadsaveobject.LoadSaveObject;

public class EntityStatList extends StatList {

    /**
     * create all stats, connect them, add them to list
     */
    public EntityStatList() {
        super();
        
        //add basic stats
        addStatToList(new Stat(StatType.EXP, 0));
        //addStatToList(new Stat(StatType.LIVES, 5));
        addStatToList(new Stat(StatType.STR, 5));
        addStatToList(new Stat(StatType.AGI, 5));
        addStatToList(new Stat(StatType.INT, 5));
        addStatToList(new Stat(StatType.HAR, 5));
        addStatToList(new Stat(StatType.MVT, 1));
        addStatToList(new Stat(StatType.VISIBILITY, 2));
        
        //add derived stats
        addStatToList(new LevelDerivedStat(StatType.LEVEL, 1, getStatObject(StatType.EXP)));
        addStatToList(new MaxHPDerivedStat(StatType.MAXHP, getStatObject(StatType.LEVEL), getStatObject(StatType.HAR)));
        addStatToList(new MaxMPDerivedStat(StatType.MAXMP, getStatObject(StatType.LEVEL), getStatObject(StatType.INT)));
        addStatToList(new ARatingDerivedStat(StatType.ARMORRATING, getStatObject(StatType.HAR)));
        addStatToList(new DRatingDerivedStat(StatType.DEFENSIVERATING, getStatObject(StatType.AGI), getStatObject(StatType.LEVEL)));
        addStatToList(new ORatingDerivedStat(StatType.OFFENSIVERATING, getStatObject(StatType.STR), getStatObject(StatType.LEVEL)));
        addStatToList(new HPDerivedStat(StatType.HP, getStatObject(StatType.MAXHP)));
        addStatToList(new MPDerivedStat(StatType.MP, getStatObject(StatType.MAXMP)));
        addStatToList(new StatPointDerivedStat(StatType.STATPOINT, getStatObject(StatType.LEVEL)));
        
        addStatToList(new LivesDerivedStat(StatType.LIVES, 5, getStatObject(StatType.HP)));
        
    }

    @Override
    public Memento getMemento() {
        return new Memento() {

            @Override
            public LoadSaveObject getState() {
                LoadSaveObject lso = EntityStatList.super.getMemento().getState();
                lso.setType("EntityStatList");
                return lso;
            }

            @Override
            public void restoreState(LoadSaveObject lso) {
                EntityStatList.super.getMemento().restoreState(lso);
            }
            
        };
    }
    
}
